<template>
  <div>
 
    <button @click="setCurrnetMenu({ID:2,MenuName:'角色管理',PageUrl:'/home/role',ParentID:1})">设置新菜单</button>
  
    <P>现在的菜单：{{getCurrentMenu}}</P>
  
    <button @click="getPublicKey">获取PublicKey</button>
  
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { mapActions } from 'vuex'

import api from '../axios/api.js'

// axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';

export default {

  computed: {
    // 使用对象展开运算符将 getters 混入 computed 对象中
    ...mapGetters([
      'getCurrentMenu'
      // ...
    ])
  },
  methods: {
    ...mapActions([
      'setCurrnetMenu'
    ]),
    getMenu: function () {
      let menu = this.getCurrentMenu;
      alert(JSON.stringify(menu))
    },
    getPublicKey: function () {
      this.$ajax.get(api.oauth.token).then(function (response) {
        console.log(response);
      }).catch(function (response) {
        console.log(response);
      });

    }
  }
}

</script>